package com.hutao.manage.util;


import java.text.DecimalFormat;
import java.text.NumberFormat;
import java.text.ParseException;

public class NumberUtil {
	private static DecimalFormat df = new DecimalFormat("#,##0.00");
	private static DecimalFormat df1 = new DecimalFormat("#,##0");

	public static double getBaiFenNumber(double handlerNum) {
		double rtNum = 0.0;
		// 1.乘以100
		rtNum = handlerNum * 100;

		// 2.保留2位小数
		NumberFormat nf = NumberFormat.getNumberInstance();
		nf.setMaximumFractionDigits(2);
		String rtNumStr = nf.format(rtNum).replaceAll(",", "");
		return Double.valueOf(rtNumStr);
	}

	public static double getLiangweiXiaoShu(double handlerNum) {
		NumberFormat nf = new DecimalFormat("#.00");
		String rtNumStr = nf.format(handlerNum);
		return Double.valueOf(rtNumStr);
	}

	public static double getXiaoShuLiangWeiNumber(double handlerNum) {
		NumberFormat nf = NumberFormat.getNumberInstance();
		nf.setMaximumFractionDigits(2);
		String rtNumStr = nf.format(handlerNum);
		Double num = 0.0;
		try {
			num = (Double) nf.parse(rtNumStr);
		} catch (ParseException e) {
			e.printStackTrace();
		}
		return num;
	}

	public static String getNotJiShuFa(Double handlerNum) {
		if (null == handlerNum) {
			return "0";
		}
		String pjfStr = df.format(handlerNum);
		return pjfStr;
	}

	public static String removeHandler(Double handlerNum) {
		if (null == handlerNum) {
			return "0";
		}
		String pjfStr = df1.format(handlerNum);
		return pjfStr;
	}
	
	
	public static void main(String[] args) {
		double opsrsLv = 97.53;
		double lastOpsrsLv = 97.80; 
		double preOpsrsLv = 97.84; 
		System.out.println((opsrsLv-preOpsrsLv) * 1.0 / preOpsrsLv);
		
		;
	}

	
}
